import { createContext } from 'react'
export const StoreContext = createContext(null)

export const initialState = { count: 0 }

export const reducer = (state, action) => {
  switch (action.type) {
    case 'increment':
      return { count: state.count + 1 }
    case 'decrement':
      return { count: state.count - 1 }
    default:
      throw new Error()
  }
}